test(spark): characterize SparkToArrowSchema Spark-to-Arrow conversion#8782
Merged
robert3005 merged 1 commit intoJul 16, 2026
Merged
Conversation
Signed-off-by: jackylee <qcsd2011@gmail.com>
071404d to
fb19e1d
Compare
robert3005
approved these changes
Jul 16, 2026
robert3005
pushed a commit
that referenced
this pull request
Jul 16, 2026
…materialization (#8783) ## Rationale for this change `PartitionPathUtils` (`java/vortex-spark/src/main/java/dev/vortex/spark/read/PartitionPathUtils.java`) discovers Hive-style partition columns from file paths and materializes them as constant column vectors on the read path. It currently has no test coverage, despite encoding several subtle behaviors: URL decoding of keys and values, the `__HIVE_DEFAULT_PARTITION__` null sentinel, first-`=` splitting, type inference precedence (int → long → double → boolean → string), and per-type parsing into `ConstantColumnVector`. This continues the characterization-test series from #8770 (read-path `ArrowUtils`) and #8782 (write-path `SparkToArrowSchema`). ## What changes are included in this PR? A new `PartitionPathUtilsTest` covering all three public methods: - **`parsePartitionValues`**: extracts ordered `key=value` segments from paths; ignores segments without the `key=value` shape (including empty keys or values); URL-decodes both keys and values (`New%20York` → `New York`); splits on the first `=` so values may themselves contain `=`. - **`inferPartitionColumnType`**: infers `Integer` for int-width values, `Long` for wider integrals, `Double` for decimal-point values, `Boolean` for case-insensitive true/false, and falls back to `String` (including for null and the `__HIVE_DEFAULT_PARTITION__` sentinel). - **`createConstantVector`**: null and the Hive default-partition sentinel produce null vectors; string/int/long/short/byte/boolean/float/double values are parsed into their target types; `DateType` parses as days-since-epoch (int) and both timestamp types as micros-since-epoch (long); unrecognized target types fall back to UTF8 strings. This is a **test-only** change; no production code is modified. 19 tests, all passing locally (`:vortex-spark_2.12:test --tests 'dev.vortex.spark.read.PartitionPathUtilsTest'`). ## What APIs are changed? Are there any user-facing changes? None. No production code or public API is touched. Signed-off-by: jackylee <qcsd2011@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
SparkToArrowSchema(java/vortex-spark/src/main/java/dev/vortex/spark/write/SparkToArrowSchema.java)converts Spark SQL schemas to Arrow schemas on the write path, and currently has no
test coverage. It is the mirror image of
ArrowUtilson the read path, which gainedcharacterization tests in #8770. Like that mapping table, this conversion is exactly the
kind of code that regresses quietly: a wrong bit width, a dropped timezone, or lost
nullability would silently corrupt written files rather than fail loudly.
What changes are included in this PR?
A new
SparkToArrowSchemaTestthat characterizes the conversion:Boolean→Bool;Byte/Short/Integer/Long→ signedInt8/16/32/64;
Float/Double→SINGLE/DOUBLEfloating point;String→Utf8;Binary→Binary;Decimal→ 128-bit ArrowDecimalpreserving precision andscale;
Date→Date(DAY);Timestamp→Timestamp(MICROSECOND, "UTC")andTimestampNTZ→Timestamp(MICROSECOND, null).is carried over to the Arrow field.
StructTypeconverts to aStructfield with recursively convertedchildren (including per-child nullability);
ArrayTypeconverts to aListwhoseelementchild carriescontainsNull.CalendarIntervalType) raiseUnsupportedOperationExceptionnaming the offending type.This is a test-only change; no production code is modified. 12 tests, all passing
locally (
:vortex-spark_2.12:test --tests 'dev.vortex.spark.write.SparkToArrowSchemaTest').What APIs are changed? Are there any user-facing changes?
None. No production code or public API is touched.